#ifndef FILESYSTEM_H_
#define FILESYSTEM_H_

#include <iostream>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <list>
#include <map>
#include <unistd.h>
#include <string.h>
#include <errno.h>

#include "types.h"
#include "Inode.h"
#include "OpenFile.h"
#include "e7convert.h"
#include "l3tol.h"
#include "Device.h"
#include "const.h"
#include "Blok.h"
#include "SuperBlok.h"

class Device;
class OpenFile;
class Inode;

class FileSystem {
private:
	Device *device;
	int amountInodeBlocks;
	int amountBlocks;
	std::list<OpenFile*>* openFileList;
	std::map<int, Inode*>* activeInodeTable;

public:
	FileSystem( const char *device );
	virtual ~FileSystem();

	Inode  *findInode( const char *absolute_path );
	Inode  *findInodeByNumber(int number);

	Blok   *getBlok(int number);
	void	releaseInode( Inode *ip );
	
	OpenFile *open( const char *path );
	int read( OpenFile *fileptr, char buffer[], int count );
	int lseek( OpenFile *fileptr, long offset, int whence );
	void close( OpenFile *fileptr );

	std::list<OpenFile*>* getSOFT();
	std::map<int, Inode*>* getAIT();
	void dumpTreeList();
};

#endif
